﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using _4_DAO;

namespace _3_DAL
{
    public class NhanVienController
    {
        static XQNDataClassesDataContext db = new XQNDataClassesDataContext();
        public static DataTable SellectAllNVLuongDAL()
        {
            DataTable dt = new DataTable();

            var query = db.NHANVIENs
                .Where(nv => nv.XoaDuLieu == false)
                .Join(db.LUONGs
                .Where(lg => lg.XoaDuLieu == false),
                nv => nv.NhanVienId,
                lg => lg.NhanVien,
                (nv, lg) => new
                {
                    nv.NhanVienId,
                    nv.TenNV,
                    nv.ChucVu,
                    nv.SDT,
                    lg.Thang,
                    lg.Nam,
                    lg.LuongNV,
                    lg.XoaDuLieu
                });
            dt.Columns.Add("ID", typeof(int));
            dt.Columns.Add("Tên Nhân Viên", typeof(string));
            dt.Columns.Add("Chức Vụ", typeof(string));
            dt.Columns.Add("Số Điện Thoại", typeof(string));
            dt.Columns.Add("Tháng", typeof(int));
            dt.Columns.Add("Năm", typeof(int));
            dt.Columns.Add("Lương", typeof(decimal));
            foreach (var item in query)
            {
                dt.Rows.Add(item.NhanVienId, item.TenNV, item.ChucVu, item.SDT, item.Thang, item.Nam, item.LuongNV);
            }
            return dt;
        }

        public static void DeleteNVDAL(List<string> keys)
        {
            throw new NotImplementedException();
        }

        public static NHANVIEN SelectNVDAL(string key)
        {
            throw new NotImplementedException();
        }

        public static void InsertNVDAL(NHANVIEN item)
        {
            throw new NotImplementedException();
        }

        public static void UpdateNVDAL(NHANVIEN item)
        {
            throw new NotImplementedException();
        }

        public static DataTable SearchNVDAL(string key)
        {
            throw new NotImplementedException();
        }
    }
}
